package kr.nextree.gae.edu.namecard.web.util;

import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import javax.ws.rs.core.Response.Status;

public class RedirectUtil {

	public static Response redirectFromBaseUri(UriInfo uriInfo, String path, String name, Object... values) {
		return Response.created(uriInfo.getBaseUriBuilder().path(path).queryParam(name, values).build()).status(Status.MOVED_PERMANENTLY).build();
	}

	public static Response redirectFromBaseUri(UriInfo uriInfo, String path) {
		return Response.created(uriInfo.getBaseUriBuilder().path(path).build()).status(Status.MOVED_PERMANENTLY).build();
	}

	public static Response redirectFromAbsoluteUri(UriInfo uriInfo) {
		return Response.created(uriInfo.getAbsolutePath()).status(Status.MOVED_PERMANENTLY).build();
	}

	public static Response redirectFromAbsoluteUriNoContent(UriInfo uriInfo) {
		return Response.created(uriInfo.getAbsolutePath()).status(Status.NO_CONTENT).build();
	}

	public static Response redirectReDMTalk(UriInfo uriInfo) {
		return RedirectUtil.redirectFromBaseUri(uriInfo, "/direct_message/rewrite");
	}
}
